ASCReader: Improve datetime parsing and support double-defined AM/PM cases#2009
Merged
zariiii9003 merged 5 commits intohardbyte:mainfrom Dec 2, 2025
Merged
Conversation
Collaborator
|
Please use black to fix the code formatting and add a news fragment. Also, here's a test you could add to @parameterized.expand(
[
("May 27 04:09:35.000 pm 2014", 1401199775.0),
("Mai 27 04:09:35.000 pm 2014", 1401199775.0),
("Apr 28 10:44:52.480 2022", 1651135492.48),
("Sep 30 15:06:13.191 2017", 1506776773.191),
("Sep 30 15:06:13.191 pm 2017", 1506776773.191),
("Sep 30 15:06:13.191 am 2017", 1506776773.191),
]
)
def test_datetime_to_timestamp(self, datetime_string: str, expected_timestamp: float):
timestamp = can.ASCReader._datetime_to_timestamp(datetime_string)
self.assertAlmostEqual(timestamp, expected_timestamp) |
Contributor
Author
|
Thank you for the detailed feedback. I updated the formatting as requested and added your test case to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
The datetime handling has been improved to robustly handle double-defined datetime strings where both a 24h timestamp and an AM/PM suffix are present (e.g.
"30 15:06:13.191 pm 2017") which previously caused parsing to fail.Key improvements:
A small unit test was used during development:
Type of Change
Checklist
tox).